<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Page extends Start_Controller {

	public function __construct(){
		parent::__construct();
		$this->load->_model('model_info','info');
	}
	
	
	public function index()
	{
		//$this->_page();
	}

    //重新定义方法的调用规则  获取URI第二段值
    public function _remap($method)
    {
        $this->_page($method);
    }
	
	/**
	 *  单页信息处理
	 */
	public function _page($id){
		
		
		$this->data['id'] = $id;
		
		
		
		//获取单页信息
		$infodata  = $this->info->get_info_items($id);
		//判断是否外链
		if($infodata['url'])
		{
			redirect($infodata['url']);
		}
		$this->data['data'] = $infodata;
		$this->data['leftmenu'] = $this->_leftmenu($infodata['classid']);
		$this->data['pagename'] = $infodata['title'];		
		$this->_template('page',$this->data);
		
    }
    
    /**
	 * 获取分类下单页信息菜单
	 */
	
	function _leftmenu($classid,$num = 10,$order='`order` asc'){
			if($classid){
				$where = " classid in ($classid)";
			}
			$result = $this->info->find_all($where,'id,title,classid', $order ,  0,  $num);
			return $result;
	}
    
	
	
	
}









